﻿using SqlSugar;

namespace RxxAdmin.Model.Logs;
[Tenant("log")]
[SplitTable(SplitType.Month)] //按月分表 （自带分表支持 年、季、月、周、日）
[SugarTable($@"{nameof(OperationLog)}_{{year}}{{month}}{{day}}")]
public class OperationLog
{
    [SugarColumn(IsNullable = false, IsPrimaryKey = true)]
    public long Id { get; set; }
    [SplitField]
    public DateTime? DateTime { get; set; }
    /// <summary>
    /// 操作模块 
    ///</summary>
    [SugarColumn(ColumnName = "Title")]
    public string? Title { get; set; }
    /// <summary>
    /// 操作类型 
    ///</summary>
    [SugarColumn(ColumnName = "OperType")]
    public OperEnum? OperType { get; set; }
    /// <summary>
    /// 请求方法 
    ///</summary>
    [SugarColumn(ColumnName = "RequestMethod")]
    public string? RequestMethod { get; set; }
    /// <summary>
    /// 操作人员 
    ///</summary>
    [SugarColumn(ColumnName = "OperUser")]
    public string? OperUser { get; set; }
    /// <summary>
    /// 操作Ip 
    ///</summary>
    [SugarColumn(ColumnName = "OperIp")]
    public string? OperIp { get; set; }
    /// <summary>
    /// 操作地点 
    ///</summary>
    [SugarColumn(ColumnName = "OperLocation")]
    public string? OperLocation { get; set; }
    /// <summary>
    /// 操作方法 
    ///</summary>
    [SugarColumn(ColumnName = "Method")]
    public string? Method { get; set; }
    /// <summary>
    /// 请求参数 
    ///</summary>
    [SugarColumn(ColumnName = "RequestParam", ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string? RequestParam { get; set; }
    /// <summary>
    /// 请求结果 
    ///</summary>
    [SugarColumn(ColumnName = "RequestResult", ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string? RequestResult { get; set; }
}

public enum OperEnum
{
    Select = 0,
    Insert = 1,
    Update = 2,
    Delete = 3,
    Auth = 4,
    Export = 5,
    Import = 6,
    ForcedOut = 7,
    GenerateCode = 8,
    ClearData = 9
}